home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / moden / admoddb.int < prev    next >
Text File  |  1996-04-08  |  5KB  |  154 lines

  1. {$G+,X+,F+}
  2.  
  3. {Conditional defines that may affect this unit}
  4. {$I AWDEFINE.INC}
  5.  
  6. {*********************************************************}
  7. {*                   ADMODDB.PAS 1.01                    *}
  8. {*        Copyright (c) TurboPower Software 1995         *}
  9. {*                 All rights reserved.                  *}
  10. {*********************************************************}
  11.  
  12. unit AdModDB;
  13.   {-Delphi modem database component}
  14.  
  15. interface
  16.  
  17. uses
  18.   {-----RTL}
  19.   SysUtils,
  20.   Classes,
  21.   Messages,
  22.   WinTypes,
  23.   DsgnIntf,
  24.   Forms,
  25.   Controls,
  26.   {-----APD}
  27.   OoMisc,
  28.   {$IFNDEF UseAPWDLL}
  29.   AwModDB,
  30.   {$ENDIF}
  31.   AdMisc,
  32.   AdExcept,
  33.   AdIniDB;
  34.  
  35. {$IFDEF UseAPWDLL}
  36. {$I AWMODDB.PA0}
  37. {$ENDIF}
  38.  
  39. const
  40.   DefModemDBName = 'AWMODEM.INI';
  41.  
  42. type
  43.   {string types for modem/modem database component data}
  44.   TModemName     = String[ModemNameLen];
  45.   TCmdString     = String[CmdLen];
  46.   TRspString     = String[RspLen];
  47.   TTagString     = String[TagLen];
  48.   TTagProfString = String[TagProfLen];
  49.   TConfigString  = String[ConfigLen];
  50.   TBoolStr       = String[BoolLen];
  51.   TBaudStr       = String[BaudLen];
  52.  
  53.   {array of response strings}
  54.   PTagArray = ^TTagArray;
  55.   TTagArray = array[1..MaxTags] of TTagString;
  56.  
  57.   {modem data}
  58.   PModemInfo = ^TModemInfo;
  59.   TModemInfo = record
  60.     Name          : TModemName;
  61.     InitCmd       : TCmdString;
  62.     DialCmd       : TCmdString;
  63.     DialTerm      : TCmdString;
  64.     DialCancel    : TCmdString;
  65.     HangupCmd     : TCmdString;
  66.     ConfigCmd     : TConfigString;
  67.     AnswerCmd     : TCmdString;
  68.     OkMsg         : TRspString;
  69.     ConnectMsg    : TRspString;
  70.     BusyMsg       : TRspString;
  71.     VoiceMsg      : TRspString;
  72.     NoCarrierMsg  : TRspString;
  73.     NoDialToneMsg : TRspString;
  74.     ErrorMsg      : TRspString;
  75.     RingMsg       : TRspString;
  76.  
  77.     NumErrors     : Word;
  78.     Errors        : TTagArray;
  79.     NumComps      : Word;
  80.     Compression   : TTagArray;
  81.     LockDTE       : Boolean;
  82.     DefBaud       : LongInt;
  83.   end;
  84.  
  85. type
  86.   TApdCustomModemDBase = class(TComponent)
  87.   protected {private}
  88.     {.Z+}
  89.     DB        : PModemDatabase;         {record passed to DLL calls}
  90.     Strs      : TStringList;            {for returning lists of modems}
  91.     Scratch   : TModemData;             {scratch record for passing into DLL}
  92.     Changed   : Boolean;                {TRUE if database data has changed}
  93.     FOpen     : Boolean;                {TRUE if database has been opened}
  94.     FFileName : String;                 {file name, used mostly at design time}
  95.  
  96.     {property read/write}
  97.     procedure SetFileName(const NewName : String);
  98.       {-Update the database's file name.  Reopen under the new name}
  99.     procedure SetOpen(const OpenIt : Boolean);
  100.       {-Open or close the database}
  101.     function GetRecordList : TStrings;
  102.       {-Returns the names of each modem in the database}
  103.     function GetNumModems : Integer;
  104.       {-Returns the number of modems in the database}
  105.  
  106.     {utility}
  107.     procedure AssureOpen;
  108.       {-Make sure that the database is open, otherwise raise an exception}
  109.     {.Z-}
  110.  
  111.   protected
  112.     property FileName : String
  113.       read FFileName write SetFileName;
  114.  
  115.   public
  116.     {.Z+}
  117.     constructor Create(AOwner : TComponent); override;
  118.     destructor Destroy; override;
  119.     {.Z-}
  120.  
  121.     procedure AddModem(const Modem : TModemInfo);
  122.       {-Add a modem to the database}
  123.     procedure UpdModem(const ModemName : TModemName; const Modem : TModemInfo);
  124.       {-Update a modem's record in the database}
  125.     procedure DelModem(const ModemName : TModemName);
  126.       {-Delete a modem from the database}
  127.     procedure GetModem(const ModemName : TModemName; var Modem : TModemInfo);
  128.       {-Get a modem from the database}
  129.     procedure WriteToIni(const Rec : TModemInfo; const Section, IniFile : String);
  130.       {-Write the modem to a user-specified .INI file}
  131.     procedure ReadFromIni(var Rec : TModemInfo; const Section, IniFile : String);
  132.       {-Read the modem from a user-specified .INI file}
  133.  
  134.     property NumModems : Integer
  135.       read GetNumModems;
  136.     property Modems : TStrings
  137.       read GetRecordList;
  138.     property Open : Boolean
  139.       read FOpen write SetOpen;
  140.   end;
  141.  
  142.   TApdModemDBase = class(TApdCustomModemDBase)
  143.   published
  144.     property FileName;
  145.   end;
  146.  
  147. {.Z+}
  148. procedure StrsToPChars(const StrRec : TModemInfo; var PCharRec : TModemData);
  149.   {-Convert a record with string variables to a record with PChars}
  150. procedure PCharsToStrs(const PCharRec : TModemData; var StrRec : TModemInfo);
  151.   {-Convert a record with PChar variables to a record with strings}
  152. {.Z-}
  153.  
  154.